package com.ityun.ogapp.adapter

import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ityun.ogapp.R
import com.ityun.ogapp.data.ContactBean

class ContactAdapter : BaseQuickAdapter<ContactBean, BaseViewHolder>(R.layout.item_contact) {
    override fun convert(holder: BaseViewHolder, item: ContactBean) {
        val rlContact = holder.getView<RelativeLayout>(R.id.rl_contact)
        if (item.id == -1L) {
            // 加载网络图片
            Glide.with(context)
                .load(R.mipmap.icon_add_contact)
                .into(holder.getView(R.id.iv_image))
            rlContact.background = null
        } else {
            Glide.with(context)
                .load(item.image)
                .error(R.mipmap.icon_girl)
                .into(holder.getView(R.id.iv_image))
            rlContact.background = ContextCompat.getDrawable(context, R.drawable.home_item_contact_bg)
        }

    }
}